//
//	MVResult.m
//
//	Create by mafeng on 13/8/2016
//	Copyright © 2016. All rights reserved.
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport



#import "MVResult.h"

NSString *const kMVResultCode = @"code";
NSString *const kMVResultData = @"data";
NSString *const kMVResultDefaultField = @"default";
NSString *const kMVResultMessage = @"message";
NSString *const kMVResultSubcode = @"subcode";

@interface MVResult ()
@end
@implementation MVResult




/**
 * Instantiate the instance using the passed dictionary values to set the properties values
 */

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
	self = [super init];
	if(![dictionary[kMVResultCode] isKindOfClass:[NSNull class]]){
		self.code = dictionary[kMVResultCode];
	}

	if(![dictionary[kMVResultData] isKindOfClass:[NSNull class]]){
		self.data = [[MVData alloc] initWithDictionary:dictionary[kMVResultData]];
	}

	if(![dictionary[kMVResultDefaultField] isKindOfClass:[NSNull class]]){
		self.defaultField = dictionary[kMVResultDefaultField];
	}

	if(![dictionary[kMVResultMessage] isKindOfClass:[NSNull class]]){
		self.message = dictionary[kMVResultMessage];
	}	
	if(![dictionary[kMVResultSubcode] isKindOfClass:[NSNull class]]){
		self.subcode = dictionary[kMVResultSubcode];
	}

	return self;
}


/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
-(NSDictionary *)toDictionary
{
	NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
	dictionary[kMVResultCode] = self.code;
	if(self.data != nil){
		dictionary[kMVResultData] = [self.data toDictionary];
	}
	dictionary[kMVResultDefaultField] = self.defaultField;
	if(self.message != nil){
		dictionary[kMVResultMessage] = self.message;
	}
	dictionary[kMVResultSubcode] = self.subcode;
	return dictionary;

}

/**
 * Implementation of NSCoding encoding method
 */
/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
- (void)encodeWithCoder:(NSCoder *)aCoder
{
	[aCoder encodeObject:self.code forKey:kMVResultCode];	if(self.data != nil){
		[aCoder encodeObject:self.data forKey:kMVResultData];
	}
	[aCoder encodeObject:self.defaultField forKey:kMVResultDefaultField];	if(self.message != nil){
		[aCoder encodeObject:self.message forKey:kMVResultMessage];
	}
	[aCoder encodeObject:self.subcode forKey:kMVResultSubcode];
}

/**
 * Implementation of NSCoding initWithCoder: method
 */
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
	self = [super init];
	self.code = [aDecoder decodeObjectForKey:kMVResultCode];
	self.data = [aDecoder decodeObjectForKey:kMVResultData];
	self.defaultField = [aDecoder decodeObjectForKey:kMVResultDefaultField];
	self.message = [aDecoder decodeObjectForKey:kMVResultMessage];
	self.subcode = [aDecoder decodeObjectForKey:kMVResultSubcode];
	return self;

}


@end
